<template>
  <div class="app-container">
    <h1>我的账户</h1>
    <div v-model="myAccount">
      <el-descriptions class="margin-top" :column="3" v-model="myAccount">
        <el-descriptions-item label="账户">{{myAccount.name}}</el-descriptions-item><br>
      </el-descriptions>
      <el-descriptions>
        <el-descriptions-item label="身份证">{{myAccount.idcard}}</el-descriptions-item>
      </el-descriptions>
      <el-descriptions>
        <el-descriptions-item label="手机号">{{myAccount.phone}}</el-descriptions-item>
      </el-descriptions>
      <el-descriptions>
        <el-descriptions-item label="余额">{{myAccount.balance}}</el-descriptions-item>
      </el-descriptions>
    </div>
    <el-button
      slot="reference"
      type="success"
      plain
      size="mini"
      @click="topUp(myAccount.id)"
      v-hasPermi="['stock:stockList:topUp']"
    >充值</el-button>

    <!--    -->
    <el-dialog
      title="充值"
      :visible.sync="dialogVisible"
      width="30%"
      :before-close="handleClose">
      <div>
        <el-radio-group v-model="myAccount.addPrice">
          <el-radio-button label="10000"></el-radio-button>
          <el-radio-button label="30000" ></el-radio-button>
          <el-radio-button label="50000"></el-radio-button>
          <el-radio-button label="80000"></el-radio-button>
        </el-radio-group>
      </div>
      <span slot="footer" class="dialog-footer">
      <el-button @click="dialogVisible = false">取 消</el-button>
      <el-button type="primary" @click="updateAccount">确 定</el-button>
      </span>
    </el-dialog>




  </div>
</template>

<script>
import {account, toPay, updateAccount} from "@/api/stock/stock";

export default {
  name: "accountIndex",
  data(){
    return{
      myAccount:{
        addPrice:''
      },
      dialogVisible:false
    }
  },methods:{
    account(){
      account().then(res=>{
        this.myAccount=res.data
      })
    },/*充值*/
    topUp(id){
      //alert(id)
      this.dialogVisible=true
    },handleClose(done) {
      this.$confirm('确认关闭？')
        .then(_ => {
          done();
        })
        .catch(_ => {});
    },updateAccount(){
      console.log(this.myAccount)
      // updateAccount(this.myAccount).then(()=>{
      //   this.$modal.msgSuccess("充值成功");
      //   this.dialogVisible=false;
      //   this.account();
      // })
      toPay(this.myAccount.name,this.myAccount.addPrice).then(res => {
        //location.href=
        let win = window.open("#","_blank");
        win.document.write(res);
        console.log(JSON.stringify(res))
        this.$modal.msgSuccess("充值成功");
        this.dialogVisible=false;
        this.account();
      })
      //location.href='http://localhost:8080/stock/klinegraph/toPay?name='+this.myAccount.name+'&addPrice='+this.myAccount.addPrice;
    }
  },created() {
    this.account();
  }
}
</script>

<style scoped lang="scss">
.home {
  blockquote {
    padding: 10px 20px;
    margin: 0 0 20px;
    font-size: 17.5px;
    border-left: 5px solid #eee;
  }
  hr {
    margin-top: 20px;
    margin-bottom: 20px;
    border: 0;
    border-top: 1px solid #eee;
  }
  .col-item {
    margin-bottom: 20px;
  }

  ul {
    padding: 0;
    margin: 0;
  }

  font-family: "open sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 13px;
  color: #676a6c;
  overflow-x: hidden;

  ul {
    list-style-type: none;
  }

  h4 {
    margin-top: 0px;
  }

  h2 {
    margin-top: 10px;
    font-size: 26px;
    font-weight: 100;
  }

  p {
    margin-top: 10px;

    b {
      font-weight: 700;
    }
  }

  .update-log {
    ol {
      display: block;
      list-style-type: decimal;
      margin-block-start: 1em;
      margin-block-end: 1em;
      margin-inline-start: 0;
      margin-inline-end: 0;
      padding-inline-start: 40px;
    }
  }
}
</style>
